package com.atguigu.executorpool;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @program: IDEAcode
 * @description:
 * @author: Mr.zjx
 * create: 2021-07-31-21-00
 **/
public class addList {
    public static void main(String[] args) {
        List<String> list = new ArrayList<String>();
        list.add("我");
        list.add("找");
        list.add("一万");
        list.add("的");
        list.add("工作");
        System.out.println("list = " + list);
        System.out.println("list.get(2) = " + list.get(2));
        String remove = list.remove(1);//会返回删除之前的元素
        System.out.println("remove = " + remove);
        list.add(1,"想");
        String set = list.set(1, "肯定");
        Iterator<String> it = list.iterator();//迭代器遍历
        while (it.hasNext()){
            System.out.print(it.next());
        }
        System.out.println();
        for (int x = 0; x < list.size(); x++){
            String s = list.get(x);
            System.out.print(s);
        }
        System.out.println(list);
        //重要
        for (String s : list){
            System.out.println(s);
        }
    }
}
